// Opening a PPC port
// Assuming inclusion of MacHeaders
#include <PPCToolBox.h>
#include <Script.h>
#include
// Prototype your function like this prior to calling it
*nbpRegisterFlag)
{
// nameScript and name should be resources to allow easy localization
thePPCPortRec.nameScript = smRoman; // Roman script
// name is a pascal style string, need to cast it to call strcpy
strcpy((char *)thePPCPortRec.name,"Inside Macintosh");
// convert back to Pascal string
CtoPstr(thePPCPortRec.name);
// the port type should always be hard-coded to allow the
// application to find ports of a particular type even after
// the name is localized
thePPCPortRec.portKindSelector = ppcByString;
// name is a pascal style string, need to cast it to call strcpy
strcpy((char *)thePPCPortRec.u.portTypeStr,"Example");
CtoPstr(thePPCPortRec.u.portTypeStr);
theLocationNameRec. locationKindSelector = ppcNBPTypeLocation;
// nbpType is a pascal style string, need to cast it to call strcpy strcpy((char *) theLocationNameRec.u.nbpType,"PPC Example"); CtoPstr( theLocationNameRec.u.nbpType); thePPCOpenPBRec.serviceType = ppcServiceRealTime;
thePPCOpenPBRec.resFlag = 0; // must be 0 for 7.0+
thePPCOpenPBRec.portName = &thePPCPortRec;
thePPCOpenPBRec. locationName = & theLocationNameRec;
// make this a visible entity on the network
thePPCOpenPBRec. networkVisible = TRUE; *thePortRefNum = thePPCOpenPBRec.portRefNum;
*nbpRegisterFlag = thePPCOpenPBRec.nbpRegistered;
return err;
}